package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.mapper.WarehouseMapper;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TWarehouse;
import com.hopu.blb_erp.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, TWarehouse> implements WarehouseService {

    @Autowired
    private WarehouseMapper warehouseMapper;

    @Override
    public Integer findCount(Integer menuId,Integer wareId,String date) {
        return warehouseMapper.selectCount(menuId,wareId,date);
    }

    @Override
    public PageEntity<TWarehouse> findPage(Integer current, Integer pageSize, Integer menuId,Integer wareId,String date) {
        Integer count = warehouseMapper.selectCount(menuId,wareId,date);
        List<TWarehouse> warehouses = warehouseMapper.selectPage((current - 1) * pageSize, pageSize,menuId,wareId,date);
        PageEntity<TWarehouse> warehousePageEntity = new PageEntity<>();
        warehousePageEntity.setData(warehouses);
        warehousePageEntity.setCurrent(current);
        warehousePageEntity.setCount(count);
        return warehousePageEntity;
    }

    @Override
    public List<TWarehouse> findTWarehouseById(String warehouseId) {
        return warehouseMapper.selectTWarehouseById(warehouseId);
    }

}
